<?php
/**
 * View helper to generate a link for a &lt;ul&gt; using &lt;li&gt;&lt;a&gt;
 */
class Zend_View_Helper_MenuLi extends Zend_View_Helper_Abstract
{
    /**
     * Generates a &lt;li&gt;&lt;a&gt; element used for menu/navigation
     * @param string $title
     * @param string $uri
     * @param string $extraClass
     * @return string &lt;li&gt;&lt;a&gt;
     */
    public function MenuLi($title, $uri, $possibleControllers = array(), $possibleActions = array(), $extraClass = null)
    {
        $classes = array();

        if (in_array(Zend_Controller_Front::getInstance()->getRequest()->getControllerName(), $possibleControllers)) {
            if (!$possibleActions) {
                $classes[] = "current";
            }

            if (is_array($possibleActions) && in_array(Zend_Controller_Front::getInstance()->getRequest()->getActionName(), $possibleActions)) {
                $classes[] = "current";
            }

        }

        if (null !== $extraClass) {
            $classes[] = $extraClass;
        }

        return '<li' . (count($classes) === 0 ? '' : ' class="' . implode(' ', $classes) . '"')
               . "><a href=\"$uri\">" . $title . "</a></li>\n";
    }
}